<%@ page import="com.bw.dao.GoodsDao" %>
<%@ page import="com.bw.pojo.Goods" %>
<%@ page import="java.util.List" %><%--
  Created by IntelliJ IDEA.
  User: Asking-mac
  Date: 2022/7/29
  Time: 16:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>数据展示页</title>

    <style>
        table,td,th{
            border: blanchedalmond 1px solid;
        }
    </style>

</head>
<body>

    <table>
        <thead>
            <tr>
                <td>id</td>
                <td>商品名称</td>
                <td>商品价格</td>
                <td>商品库存</td>
                <td>商品介绍</td>
                <td>上架时间</td>
            </tr>
        </thead>

        <tbody>
            <%
                List<Goods> list = null;
                if(request.getAttribute("list") == null){
                    list = new GoodsDao().selectAllGoods();
                }else{
                    list = (List<Goods>) request.getAttribute("list");
                }
            %>

            <% for(int i = 0;i < list.size();i++) { %>
                    <tr>
                        <td><%=list.get(i).getId()%></td>
                        <td><%=list.get(i).getGoods_name()%></td>
                        <td><%=list.get(i).getGoods_price()%></td>
                        <td><%=list.get(i).getGoods_stock()%></td>
                        <td><%=list.get(i).getGoods_des()%></td>
                        <td><%=list.get(i).getGoods_up_time()%></td>
                    </tr>
            <% } %>
        </tbody>

    </table>

    <input type="button" value="前往新增页" onclick="func()">
    <input type="button" value="按照价格降序排序" onclick="funcOrder()">





</body>


    <script>
        function func(){
        	window.location.href = "insert.jsp";
        }


        function funcOrder(){
        	window.location.href = "SelectOrderPriceServlet";
        }

    </script>


</html>
